<?php
    include($_SERVER["DOCUMENT_ROOT"].'/CTAN/models/tietmuc.php');
    $tietmuc = new tietmuc();

    if (isset($_REQUEST['action'])){
        $action = ($_REQUEST['action']);
        if ($action=="insert"){
            //INSERT COMMAND
            $mabuoidien = $_REQUEST['ma_buoi_dien'];
            $tentietmuc = $_REQUEST['ten_tiet_muc'];
            echo $tietmuc->themTietMucVaoBuoiDien($mabuoidien, $tentietmuc);
            //echo $result;
        }
        elseif ($action=="edit") {
            // UPDATE COMMAND
            $tietmuc->setMaTietMuc($_REQUEST['ma_tiet_muc']);
            $tietmuc->setTenTietMuc($_REQUEST['ten_tiet_muc']);
            echo $tietmuc->updateToDB();
            //echo $result;
        }
        elseif ($action=="delete") {
            $tietmuc->setMaTietMuc($_REQUEST['matietmuc']);
            echo $tietmuc->deleteFromDB();
        }
    }
?>
